from enum import Enum

from pydantic import BaseModel


class Engine(Enum):
    Redis = "redis://"
    SqLite3 = "sqlite://"
    MySQL = "mysql://"
    PostgreSQL = "postgres://"  # ?sslmode=disable


class MetadataEngine(BaseModel):
    engine: Engine
    host_url: str
    port: int | None = None
    db_name: str | None = None
    username: str | None = None
    password: str | None = None


class Storage(Enum):
    S3 = "s3"
    MinIO = "minio"
    SFTP = "sftp"
    AliCloudOSS = "oss"
    TencentCOS = "cos"
    HuaweiOBS = "obs"


class ObjectStorage(BaseModel):
    provider: Storage
    bucket_url: str
    access_key: str
    secret_key: str


class S3GatewayConfig(BaseModel):
    listen_url: str
    port: int
    access_key: str
    secret_key: str


class WebDAVConfig(BaseModel):
    listen_url: str
    port: int
    user: str
    password: str


class FileSystem(BaseModel):
    name: str
    metadata: MetadataEngine
    object_store: ObjectStorage
    s3_gateway: S3GatewayConfig | None = None
    webdav_gateway: WebDAVConfig | None = None


class FileSystemInDB(BaseModel):
    id: str | None = None
    name: str
    uuid: str
    fs_definition: str
